#include "cellwidget.h"
#include <QDebug>

const QString CellWidget::unknown_cell_value = "?????";

CellWidget::CellWidget(){
}


CellWidget::CellWidget(const CellWidget &other) : QTableWidgetItem(other)
{
}

QTableWidgetItem *CellWidget::clone() const
{
  return new CellWidget(*this);
}


void CellWidget::setData(const QVariant &value, int role)
{
  QTableWidgetItem::setData(role, value);
}

void CellWidget::setText(const QString &value)
{
  QTableWidgetItem::setText(value);
}

QVariant CellWidget::data(int role) const
{
  if (role == Qt::DisplayRole) {
    if (data().isValid()) {
      return data().toString();
    } else {
      return unknown_cell_value;
    }
  } else if (role == Qt::TextAlignmentRole) {
    if (data().type() == QVariant::String) {
       return int(Qt::AlignLeft | Qt::AlignVCenter);
    } else {
       return int(Qt::AlignRight | Qt::AlignVCenter);
    }
  } else {
    return QTableWidgetItem::data(role);
  }
}

